<?php get_instance()->view('common/header');?>
<style type="text/css">
    .portrait{max-width: 100%}
</style>
<div class="page-container home">
    <?php get_instance()->view('common/sidebar');?>
    <div class="page-content-wrapper">
        <div class="page-content">
            <div class="row">
                <div class="col-md-12">
                    <!-- BEGIN PAGE TITLE & BREADCRUMB-->
                    <h3 class="page-title"> <?php echo $title?></h3>
                    <ul class="page-breadcrumb breadcrumb">
                        <li><i class="fa fa-home"></i> <a href="javascript:;">批量消息推送 </a></li>
                    </ul>
                    <!-- END PAGE TITLE & BREADCRUMB-->
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <!-- BEGIN FORM-->
                    <form action="<?php echo getUrl('message/consumer/save');?>" class="form-horizontal" id="model-form" method="post">
                        <div class="form-group">
                            <label class="control-label col-md-1">标题</label>
                            <div class="col-md-6">
                                <input type="text" name="title" class="form-control required"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-1">简介</label>
                            <div class="col-md-6">
                                <textarea class="form-control required" rows="3" style="height:100px;"  name="content"></textarea>
                                <input type="hidden" name="ids">
                                <input type="hidden" name="consumer_ids">
                            </div>
                        </div>
			             <div class="form-group">
                            <label class="control-label col-md-1">详细内容</label>
                            <div class="col-md-6">
                                <script id="content" name="content_detail" type="text/plain" ></script>

                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-1">推送类型</label>
                            <div class="col-md-6">
                                <select name="type" class="form-control">
                                    <option value="2">指定人</option>
                                    <option value="1">所有人</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-actionsc fluid">
                            <div class="col-md-offset-1 col-md-9" style="padding-left:0;">
                                <button class="btn green submit"><i class="fa fa-save"></i> 确认推送</button>
                                <a href="<?php echo getUrl('message/consumer/history');?>" class="btn default"><i class="fa  fa-bars"></i> 推送历史</a>
                            </div>
                        </div>
                    </form>
                    <div class="form-group">
                        <div class="col-md-5">
                            <span class="help-block" style="padding-left: 120px">温馨提示：选中状态仅作用于当前列表</span>
                        </div>
                    </div>
                    <!-- END FORM-->
                </div>
            </div>
            <div style="height: 50px"></div>
            <div class="row">
                <div class="col-md-12">
                    <div class="portlet">
                        <div class="portlet-body">
                            <div class="table-container">
                                <table class="table table-bordered table-hover" id="datatable">
                                    <thead>
                                    <tr role="row" class="heading">
                                        <th width="3%" class="table-checkbox">
                                            <input type="checkbox" class="group-checkable" data-set="#sample_1 .checkboxes"/>
                                        </th>
                                        <th width="50px" sort="false"> 头像 </th>
                                        <th  sort="false">真实姓名</th>
                                        <th width="16%" sort="false">昵称</th>
                                        <th width="15%" sort="false">手机号码</th>
                                        <th width="15%" sort="false">最近登录</th>
                                        <th width="15%" sort="false">状态</th>
                                        <th width="15%" sort="false">操作</th>
                                    </tr>
                                    <tr>
                                        <th></th>
                                        <th></th>
                                        <th><input class="form-control form-filter input-sm" name="realname" type="text"></th>
                                        <th><input class="form-control form-filter input-sm" name="nickname" type="text"></th>
                                        <th><input class="form-control form-filter input-sm" name="mobile" type="text"></th>
                                        <th></th>
                                        <th>
                                            <select name="status" class="form-control form-filter input-sm">
                                                <option value="0" selected>所有</option>
                                                <option value="1">禁用</option>
                                                <option value="2">启用</option>
                                            </select>
                                        </th>
                                        <th>
                                            <div class="btn-group">
                                                <a class="btn btn-xs filter-submit btn-default"><i class="fa fa-search"></i> 搜索</a>
                                                <button data-toggle="dropdown" class="btn btn-default dropdown-toggle btn-xs" type="button"><i class="fa fa-angle-down"></i></button>
                                                <ul role="menu" class="dropdown-menu pull-right">
                                                    <li><a href="javascript:void(0);" class="filter-cancel">重置</a></li>
                                                </ul>
                                            </div>
                                        </th>
                                    </tr>
                                    </thead>
                                    <tbody></tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function(){
        $.e_validate.init('.form-horizontal',{});
        UE.getEditor('content',{initialFrameWidth:'800',initialFrameHeight:'200',autoHeightEnabled:false,serverUrl:'<?php echo getUrl('message/merchant/editor');?>'});
    });
    $(function(){

        datatable_init({
            src: $("#datatable"),
            sAjaxSource: "<?php echo getUrl('message/consumer/getConsumerList');?>",
            aoColumnDefs : [{
                'bSortable' : false,
                'aTargets' : [ 0,1,2,4,6,7]
            }],
            aLengthMenu : [50,100, 200, 500], //更改显示记录数选项
            iDisplayLength : 50 //默认显示的记录数
        });
        var model = $('#model-form');
        $('.submit').click(function(){
            var id =$("input[type='checkbox']:checked");
            if(id.length == 0)
            {
                show_message({status:0, message:'请选择用户'});
                return false;
            }
            var consumerId = 0;
            id.each(function(){
                consumerId += ','+$(this).val();

            });
            model.find('[name="consumer_ids"]').val(consumerId);
        });

        $.e_validate.init('#model-form',{successCallback:function(){
				$('[name="content"]').val('');
				$('[type="submit"]').attr('disabled', false);
				$('[type="checkbox"]').attr('checked', false).uniform();
                $("input").val('');
          }});

        /**
         * 单个选择
         */
//        $(".confirm-btn").live('click',function () {
//            $("[name='ids']").val($(this).attr('data-id'));
//            $(".submit").submit();
//        });
    });
</script>
</body>
</html>
